$tab-inactive-color: $cloudy;
$tab-hover-color: white;
$tab-active-color: $aqua;
$tab-hover-bg: rgba(255, 255, 255, 0.1);
$tab-active-bg: $snow;
$tab-transition-duration: 200ms;
$tab-border-radius-top: 8px;
$tab-border-radius-bottom: 6px;

@mixin tab-border {
  content: " ";
  position: absolute;
  background-color: rgba(255, 255, 255, 0.4);
  width: 1px;
  top: 6px;
  bottom: 6px;
  opacity: 1;
}

.tab-bar .tab {
  position: absolute;
  left: 0;
  user-select: none;
  -webkit-app-region: no-drag;
  height: 34px;
  padding: 0;
  padding-bottom: 3px;
  background: transparent;
  cursor: default;
  border-radius: $tab-border-radius-top $tab-border-radius-top 0 0;
  will-change: transform;
  transition: none;

  .tab-content {
    overflow: hidden;
    display: flex;
    justify-content: space-between;
    align-items: center;
    height: 100%;
    position: relative;
  }

  .loading {
    position: absolute;
    left: 10px;
    top: 6px;
    transform: translateX(-30px);
  }

  // the little line when the tab is not active
  // &:before {
  //   @include tab-border;
  //   left: 0;
  // }

  // &:last-of-type:after {
  //   @include tab-border;
  //   left: 100%;
  // }

  // &:first-child:before {
  //   display: none;
  // }

  // The little swooshes on active and hovered tabs
  .ramp {
    position: absolute;
    bottom: 0;
    fill: transparent;
    width: $tab-border-radius-bottom;
    height: $tab-border-radius-bottom;
  }
  .ramp-right {
    left: 100%;
  }
  .ramp-left {
    right: 100%;
  }

  // Title
  .title {
    font-family: system-ui;
    font-size: 12px;
    margin: 0;
    font-weight: 500;
    color: $tab-inactive-color;
    white-space: nowrap;
    overflow: hidden;
    text-overflow: ellipsis;
    padding-left: 10px;
    flex: 1;
  }

  // Close x icon
  .close-button {
    width: 17px;
    height: 17px;
    min-width: 17px;
    margin-right: 10px;
    svg {
      width: 9px;
      height: 9px;
      fill: $tab-inactive-color;
    }
    &:after {
      content: "";
      width: 17px;
      height: 17px;
      background: rgba(255, 255, 255, 0.2);
      border-radius: 50%;
      position: absolute;
      top: 0;
      left: 0;
      transform: scale(0);
    }
    &:hover {
      svg {
        fill: $white-1;
      }
      &:after {
        transition: transform 100ms;
        transform: scale(1);
      }
    }
    &:active:after {
      background: rgba(255, 255, 255, 0.3);
    }
  }

  // The hover state
  &:hover {
    background-color: $tab-hover-bg;
    //  transition: background-color $tab-transition-duration;
    // &:before,
    // & + .tab:before,
    // &:last-of-type:after {
    //   transition: opacity $tab-transition-duration;
    //   opacity: 0;
    // }
    .ramp {
      fill: $tab-hover-bg;
    }
    .title {
      color: $tab-hover-color;
    }
    .close-button svg {
      fill: $tab-hover-color;
    }
  }

  // The active state
  &.active {
    background: $tab-active-bg;
    z-index: 1;
    .ramp {
      fill: $tab-active-bg;
    }

    // &:before,
    // & + .tab:before,
    // &:last-of-type:after {
    //   transition: none;
    //   opacity: 0;
    // }

    .title {
      color: $tab-active-color;
    }
    .close-button {
      svg {
        fill: $tab-active-color;
      }
      &:after {
        background: rgba(0, 0, 0, 0.1);
      }
      &:active:after {
        background: rgba(0, 0, 0, 0.2);
      }
    }
  }

  &.is-new.active {
    background: white;
  }
}
